<template>
	<section>
		<el-row class="app-container"> 
		<!--编辑界面 ImGroupCategory 分类--> 
			<el-form :model="editForm"  label-width="120px" :rules="editFormRules" ref="editForm">
				<el-form-item label="分类编号" prop="id">
					<el-input v-model="editForm.id" placeholder="分类编号"></el-input>
				</el-form-item> 
				<el-form-item label="分类名称" prop="categoryName">
					<el-input v-model="editForm.categoryName" placeholder="分类名称"></el-input>
				</el-form-item> 
				<el-form-item label="归属机构号" prop="branchId">
					<el-input v-model="editForm.branchId" placeholder="归属机构号"></el-input>
				</el-form-item> 
				<el-form-item label="业务类型C咨询M投诉N通知/公告S物流T普通聊天" prop="bizType">
					<el-input v-model="editForm.bizType" placeholder="业务类型C咨询M投诉N通知/公告S物流T普通聊天"></el-input>
				</el-form-item> 
				<el-form-item label="业务对象L门店P商品K规格O订单S物流T其他M手机号码W微信号码M邮箱" prop="bizObject">
					<el-input v-model="editForm.bizObject" placeholder="业务对象L门店P商品K规格O订单S物流T其他M手机号码W微信号码M邮箱"></el-input>
				</el-form-item> 
				<el-form-item label="响应者类型：CSS客服、MEM会员、PL平台" prop="resType">
					<el-input v-model="editForm.resType" placeholder="响应者类型：CSS客服、MEM会员、PL平台"></el-input>
				</el-form-item> 
				<el-form-item label="最大响应人数1代表同时只有一个人应答0代表不限制" prop="maxResUser">
					<el-input v-model="editForm.maxResUser" placeholder="最大响应人数1代表同时只有一个人应答0代表不限制"></el-input>
				</el-form-item> 
				<el-form-item label="允许最大人数" prop="maxUsers">
					<el-input v-model="editForm.maxUsers" placeholder="允许最大人数"></el-input>
				</el-form-item> 
				<el-form-item label="是否允许加入0不允许1允许" prop="allowJoin">
					<el-input v-model="editForm.allowJoin" placeholder="是否允许加入0不允许1允许"></el-input>
				</el-form-item> 
				<el-form-item label="是否需要审核0不需要1需要" prop="needAudit">
					<el-input v-model="editForm.needAudit" placeholder="是否需要审核0不需要1需要"></el-input>
				</el-form-item> 
				<el-form-item> 
					<el-col :span="24" :offset="8"> 
						<el-button @click.native="handleCancel">取消</el-button>  
						<el-button v-loading="load.edit" type="primary" @click.native="editSubmit" :disabled="load.edit==true">提交</el-button>  
					</el-col> 
				</el-form-item> 
			</el-form>
		</el-row>
	</section>
</template>

<script>
	import util from '@/common/js/util';//全局公共库
	//import { listOption } from '@/api/mdp/meta/itemOption';//下拉框数据查询
	import { editImGroupCategory } from '@/api/mdp/im/group/imGroupCategory';
	import { mapGetters } from 'vuex'
	
	export default { 
		computed: {
		    ...mapGetters([
		      'userInfo'
		    ])
		},
		props:['imGroupCategory','visible'],
		watch: {
	      'imGroupCategory':function( imGroupCategory ) {
	        this.editForm = imGroupCategory;
	      },
	      'visible':function(visible) { 
	      	if(visible==true){
	      		//从新打开页面时某些数据需要重新加载，可以在这里添加
	      	}
	      } 
	    },
		data() {
			return {
				options:{},//下拉选择框的所有静态数据 params=[{categoryId:'0001',itemCode:'sex'}] 返回结果 {'sex':[{optionValue:'1',optionName:'男',seqOrder:'1',fp:'',isDefault:'0'},{optionValue:'2',optionName:'女',seqOrder:'2',fp:'',isDefault:'0'}]} 
				load:{ list: false, edit: false, del: false, add: false },//查询中...
				editFormRules: {
					id: [
						//{ required: true, message: '分类编号不能为空', trigger: 'blur' }
					]
				},
				//编辑界面数据  ImGroupCategory 分类
				editForm: {
					id:'',categoryName:'',branchId:'',bizType:'',bizObject:'',resType:'',maxResUser:'',maxUsers:'',allowJoin:'',needAudit:''
				}
				/**begin 在下面加自定义属性,记得补上面的一个逗号**/
				
				/**end 在上面加自定义属性**/
			}//end return
		},//end data
		methods: {
			// 取消按钮点击 父组件监听@cancel="editFormVisible=false" 监听
			handleCancel:function(){
				this.$refs['editForm'].resetFields();
				this.$emit('cancel');
			},
			//编辑提交ImGroupCategory 分类父组件监听@submit="afterEditSubmit"
			editSubmit: function () {
				this.$refs.editForm.validate((valid) => {
					if (valid) {
						this.$confirm('确认提交吗？', '提示', {}).then(() => { 
							this.load.edit=true
							let params = Object.assign({}, this.editForm); 
							editImGroupCategory(params).then((res) => {
								this.load.edit=false
								var tips=res.data.tips;
								if(tips.isOk){
									this.$refs['editForm'].resetFields();
									this.$emit('submit');//  @submit="afterEditSubmit"
								}
								this.$message({ message: tips.msg, type: tips.isOk?'success':'error' }); 
							}).catch( err =>this.load.edit=false);
						});
					}
				});
			}
			/**begin 在下面加自定义方法,记得补上面的一个逗号**/
				
			/**end 在上面加自定义方法**/
		},//end method
		components: {  
		    //在下面添加其它组件 'im-group-category-edit':ImGroupCategoryEdit
		},
		mounted() {
			this.editForm=Object.assign(this.editForm, this.imGroupCategory);  
		}
	}

</script>

<style scoped>

</style>